package com.start.workflow.model;

import cn.hutool.core.date.LocalDateTimeUtil;
import com.alibaba.fastjson2.JSONObject;
import com.start.workflow.entity.StartActReModelExt;
import io.swagger.v3.oas.annotations.media.Schema;

import lombok.Data;
import org.activiti.engine.repository.Model;

import java.time.LocalDateTime;

@Data
 @Schema(name="流程模型对象")
public class StartProcessModel extends StartActReModelExt {
     @Schema(name="模型名称")
    private String actModelName;
     @Schema(name="模型key")
    private String actModelKey;
     @Schema(name="模型分组")
    private String actModelCategory;
     @Schema(name="最后一次修改时间")
    private LocalDateTime lastUpdateTime;
     @Schema(name="创建时间")
    private LocalDateTime createTime;
     @Schema(name="租户id")
    private String tenantId;
     @Schema(name="版本")
    private Integer actModelVersion;

     @Schema(name="bpmnXml")
    private String bpmnXml;

     @Schema(name="bpmnJSON")
    private JSONObject bpmnJson;

    public StartProcessModel() {

    }

    public StartProcessModel(Model model, StartActReModelExt startActReModelExt) {
        StartProcessModel startProcessModel = new StartProcessModel();
        startProcessModel.setId(model.getId());
        startProcessModel.setActModelCategory(model.getCategory());
        startProcessModel.setActModelVersion(model.getVersion());
        startProcessModel.setCreateTime(LocalDateTimeUtil.of(model.getCreateTime()));
        startProcessModel.setLastUpdateTime(LocalDateTimeUtil.of(getLastUpdateTime()));
        startProcessModel.setModelIcon(startActReModelExt.getModelIcon());
        startProcessModel.setSort(startActReModelExt.getSort());
    }
}
